﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ControlesPadroes;

namespace InterfaceWinForm
{
    public partial class BrowsePadrao : Telerik.WinControls.UI.RadForm
    {
        private EnumOpenBrowse _OpenBrowse;
     

        public EnumOpenBrowse OpenBrowse
        {
            get { return _OpenBrowse; }
            set { _OpenBrowse = value; }
        }


        #region construtores
        public BrowsePadrao()
        {
            InitializeComponent();
                   
        }
        #endregion
 
        protected void InicializarBrowse()
        {
            CarregarGrid();

            if (OpenBrowse == EnumOpenBrowse.Selecao)
            {
                radButtonSelecionar.Visible = true;
                selecionarToolStripMenuItem.Visible = true;
            }
            else
            {
                radButtonSelecionar.Visible = false;
                selecionarToolStripMenuItem.Visible = true;
            }

        }


        protected void RetornarInformacao(string pTitulo, string pInformacao )
        {
            MessageBox.Show(pTitulo, pInformacao);

        }
  

        private void OpenForm(EnumOpenForm pOpenForm)
        {          
            if ( InformarForm(CriarObjeto(), pOpenForm) )
                CarregarGrid();                       
        }

       
        #region menupoup

        private void fecharToolStripMenuItem_Click(object sender, EventArgs e)
        {
            radButtonFechar_Click(sender, e);
        }

        private void selecionarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            radButtonSelecionar_Click(sender, e);
        }

        private void alterarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            radButtonAlterar_Click(sender, e);
        }

        private void consultarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            radButtonConsultar_Click(sender, e);
        }

        private void excluirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            radButtonExcluir_Click(sender, e);
        }

        private void incluirToolStripMenuItem_Click(object sender, EventArgs e)
        {
            radButtonIncluir_Click(sender, e);
        } 


        #endregion

        #region botoes

        private void radButtonFechar_Click(object sender, EventArgs e)
        {
            Close();
        }


        private void radButtonSelecionar_Click(object sender, EventArgs e)
        {
            
        }

        private void radButtonIncluir_Click(object sender, EventArgs e)
        {
            OpenForm(EnumOpenForm.Incluir);
        }

        private void radButtonAlterar_Click(object sender, EventArgs e)
        {
            OpenForm(EnumOpenForm.Alterar);
        }

        private void radButtonConsultar_Click(object sender, EventArgs e)
        {
            OpenForm(EnumOpenForm.Consultar);
        }

        private void radButtonExcluir_Click(object sender, EventArgs e)
        {
            OpenForm(EnumOpenForm.Excluir);
        }
        #endregion


        #region customizavel

        protected virtual bool InformarForm(Object pObjeto, EnumOpenForm pOpenform)
        {
            throw new NotImplementedException();
        }

        protected virtual Object CriarObjeto()
        {
            throw new NotImplementedException();
        }

        protected virtual void CarregarGrid()
        {
            throw new NotImplementedException();
        }
        

        #endregion

    }
}
